public class Test {
    //设想：append不会产生临时对象，永远返回某个对象，那么他是否改变了那个对象？
    public static void main(String[] args) {

    }
    public static void main3(String[] args) {
        StringBuilder stringBuilder = new StringBuilder("abc");
        System.out.println(stringBuilder);

        stringBuilder.append("123").append(10);//字符串的拼接
        System.out.println(stringBuilder);

        String ret = stringBuilder.toString();

        stringBuilder.reverse();//实现逆序
        System.out.println(stringBuilder);
    }
    public static void main2(String[] args) {
        String str = "hello";
        str += "abc";
        System.out.println(str);
    }
    public static void main1(String[] args) {
        String str = "hello";//一个对象
        //
        StringBuilder stringBuilder = new StringBuilder();//两个对象
        stringBuilder.append(str);
        stringBuilder.append("abc");
        //这三行相当于上面的“str += "abc"”

        str = stringBuilder.toString();//三个对象
        System.out.println(str);//四个对象
    }
}
